package homework22;

public class TestABC {
    public static void main(String[] args) {
        C c = new C();

        // 访问C类继承的字段
        System.out.println("a = " + c.a);       // 输出：a = 1 (来自A类)
        System.out.println("b = " + c.b);       // 输出：b = 2 (来自B类)
        System.out.println("c = " + c.c);       // 输出：c = 3 (来自C类)

        // 访问各层的name字段（就近原则）
        System.out.println("c.name = " + c.name);  // 输出：c.name = C (来自C类)
        System.out.println("((B)c).name = " + ((B)c).name);  // 输出：((B)c).name = B (来自B类)
        System.out.println("((A)c).name = " + ((A)c).name);  // 输出：((A)c).name = A (来自A类)
    }
}
